package com.sidianzhong.sdz.controller;

import com.alibaba.fastjson.JSONObject;
import com.sidianzhong.sdz.annotation.BackLoginToken;
import com.sidianzhong.sdz.annotation.UserLoginToken;
import com.sidianzhong.sdz.model.*;
import com.sidianzhong.sdz.service.*;
import com.sidianzhong.sdz.service.commond.RedisService;
import com.sidianzhong.sdz.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;

/**
 * Created by hxg on 2016/10/06.
 */
@Api(description = "币种信息")
@Controller
public class CoinInfoController {

    @Autowired
    CoinInfoService coinInfoService;
    @Autowired
    HttpServletRequest request;
    @Autowired
    HttpServletResponse response;

    @BackLoginToken
    @ApiOperation(value = "创建'币种信息'表中一条信息")
    @RequestMapping(value = "/coinInfo/new", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object createCoinInfo(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token") String token,
            @RequestParam(value = "coinId", required = false) Integer coinId,
            @RequestParam(value = "coinEnglishName", required = false) String coinEnglishName,
            @RequestParam(value = "coinSymbol", required = false) String coinSymbol,
            @RequestParam(value = "coinUrl", required = false) String coinUrl,
            @RequestParam(value = "coinChineseName", required = false) String coinChineseName,
            @RequestParam(value = "coinContractAddress", required = false) String coinContractAddress,
            @RequestParam(value = "coinDecimal", required = false) Integer coinDecimal,
            @RequestParam(value = "coinDecimalUsed", required = false) Integer coinDecimalUsed,
            @RequestParam(value = "coinQuotesName", required = false) String coinQuotesName,
            @RequestParam(value = "coinLocation", required = false) String coinLocation,
            @RequestParam(value = "coinPriceRmb", required = false) Double coinPriceRmb,
            @RequestParam(value = "coinPriceUsdt", required = false) String coinPriceUsdt,
            @RequestParam(value = "coinFluctuation", required = false) String coinFluctuation,
            @RequestParam(value = "coinPriceUpdatetime", required = false) String coinPriceUpdatetime,
            @RequestParam(value = "coinFluctuationUpdatetime", required = false) String coinFluctuationUpdatetime,
            @RequestParam(value = "coinPriceRequestpath", required = false) String coinPriceRequestpath,
            @RequestParam(value = "coinPriceJsonStructure", required = false) String coinPriceJsonStructure,
            @RequestParam(value = "coinPriceRequestmethod", required = false) String coinPriceRequestmethod,
            @RequestParam(value = "coinPriceRequestbody", required = false) String coinPriceRequestbody,
            @RequestParam(value = "coinFluctuationJsonStructure", required = false) String coinFluctuationJsonStructure,
            @RequestParam(value = "coinFluctuationRequestpath", required = false) String coinFluctuationRequestpath,
            @RequestParam(value = "coinFluctuationRequestmethod", required = false) String coinFluctuationRequestmethod,
            @RequestParam(value = "isdisplay", required = false) Integer isdisplay,
            @RequestParam(value = "coinFluctuationRequestbody", required = false) String coinFluctuationRequestbody,
            @RequestParam(value = "coinSort", required = false) Integer coinSort,
            @RequestParam(value = "isSync", required = false) Integer isSync
    ) {
        CoinInfo item = new CoinInfo();
        Date date = new Date();
        if (coinId != null) {
            item.setCoinId(coinId);
        }
        if (coinEnglishName != null) {
            item.setCoinEnglishName(coinEnglishName);
        }
        if (coinSymbol != null) {
            item.setCoinSymbol(coinSymbol);
        }
        if (coinUrl != null) {
            item.setCoinUrl(coinUrl);
        }
        if (coinChineseName != null) {
            item.setCoinChineseName(coinChineseName);
        }
        if (coinContractAddress != null) {
            item.setCoinContractAddress(coinContractAddress);
        }
        if (coinDecimal != null) {
            item.setCoinDecimal(coinDecimal);
        }
        if (coinDecimalUsed != null) {
            item.setCoinDecimalUsed(coinDecimalUsed);
        }
        if (coinQuotesName != null) {
            item.setCoinQuotesName(coinQuotesName);
        }
        if (coinLocation != null) {
            item.setCoinLocation(coinLocation);
        }
        if (coinPriceRmb != null) {
            item.setCoinPriceRmb(coinPriceRmb);
        }
        if (coinPriceUsdt != null) {
            item.setCoinPriceUsdt(coinPriceUsdt);
        }
        if (coinFluctuation != null) {
            item.setCoinFluctuation(coinFluctuation);
        }
        if (coinPriceUpdatetime != null) {
            item.setCoinPriceUpdatetime(date);
        }
        if (coinFluctuationUpdatetime != null) {
            item.setCoinFluctuationUpdatetime(date);
        }
        if (coinPriceRequestpath != null) {
            item.setCoinPriceRequestpath(coinPriceRequestpath);
        }
        if (coinPriceJsonStructure != null) {
            item.setCoinPriceJsonStructure(coinPriceJsonStructure);
        }
        if (coinPriceRequestmethod != null) {
            item.setCoinPriceRequestmethod(coinPriceRequestmethod);
        }
        if (coinPriceRequestbody != null) {
            item.setCoinPriceRequestbody(coinPriceRequestbody);
        }
        if (coinFluctuationJsonStructure != null) {
            item.setCoinFluctuationJsonStructure(coinFluctuationJsonStructure);
        }
        if (coinFluctuationRequestpath != null) {
            item.setCoinFluctuationRequestpath(coinFluctuationRequestpath);
        }
        if (coinFluctuationRequestmethod != null) {
            item.setCoinFluctuationRequestmethod(coinFluctuationRequestmethod);
        }
        if (isdisplay != null) {
            item.setIsdisplay(isdisplay);
        }
        if (coinFluctuationRequestbody != null) {
            item.setCoinFluctuationRequestbody(coinFluctuationRequestbody);
        }
        if (coinSort != null) {
            item.setCoinSort(coinSort);
        }
        if (isSync != null) {
            item.setIsSync(isSync);
        }
        CoinInfo iteams = coinInfoService.create(item);
        boolean result = iteams != null;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", result);
        return new ResponseEntity<>(ResultModel.ok(jsonObject), HttpStatus.OK);
    }

    @BackLoginToken
    @ApiOperation(value = "删除'币种信息'表中的某条记录")
    @RequestMapping(value = "/coinInfo/delete", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object deleteCoinInfo(
            @RequestHeader(value = "X-Auth-Token") String token,
            @RequestParam(value = "id") Integer id
    ) {
        CoinInfo item = coinInfoService.get(id);
        if (null == item) {
            return new ResponseEntity<>(ResultModel.error(), HttpStatus.OK);
        }
        int delete = coinInfoService.delete(id);
        boolean result = delete != 0;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", result);
        return new ResponseEntity<>(ResultModel.ok(jsonObject), HttpStatus.OK);
    }

    @BackLoginToken
    @ApiOperation(value = "修改'币种信息'表中的某条记录")
    @RequestMapping(value = "/coinInfo/edit", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object editCoinInfo(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token") String token,
            @RequestParam(value = "id") Integer id,
            @RequestParam(value = "coinId", required = false) Integer coinId,
            @RequestParam(value = "coinEnglishName", required = false) String coinEnglishName,
            @RequestParam(value = "coinSymbol", required = false) String coinSymbol,
            @RequestParam(value = "coinUrl", required = false) String coinUrl,
            @RequestParam(value = "coinChineseName", required = false) String coinChineseName,
            @RequestParam(value = "coinContractAddress", required = false) String coinContractAddress,
            @RequestParam(value = "coinDecimal", required = false) Integer coinDecimal,
            @RequestParam(value = "coinDecimalUsed", required = false) Integer coinDecimalUsed,
            @RequestParam(value = "coinQuotesName", required = false) String coinQuotesName,
            @RequestParam(value = "coinLocation", required = false) String coinLocation,
            @RequestParam(value = "coinPriceRmb", required = false) Double coinPriceRmb,
            @RequestParam(value = "coinPriceUsdt", required = false) String coinPriceUsdt,
            @RequestParam(value = "coinFluctuation", required = false) String coinFluctuation,
            @RequestParam(value = "coinPriceUpdatetime", required = false) String coinPriceUpdatetime,
            @RequestParam(value = "coinFluctuationUpdatetime", required = false) String coinFluctuationUpdatetime,
            @RequestParam(value = "coinPriceRequestpath", required = false) String coinPriceRequestpath,
            @RequestParam(value = "coinPriceJsonStructure", required = false) String coinPriceJsonStructure,
            @RequestParam(value = "coinPriceRequestmethod", required = false) String coinPriceRequestmethod,
            @RequestParam(value = "coinPriceRequestbody", required = false) String coinPriceRequestbody,
            @RequestParam(value = "coinFluctuationJsonStructure", required = false) String coinFluctuationJsonStructure,
            @RequestParam(value = "coinFluctuationRequestpath", required = false) String coinFluctuationRequestpath,
            @RequestParam(value = "coinFluctuationRequestmethod", required = false) String coinFluctuationRequestmethod,
            @RequestParam(value = "isdisplay", required = false) Integer isdisplay,
            @RequestParam(value = "coinFluctuationRequestbody", required = false) String coinFluctuationRequestbody,
            @RequestParam(value = "coinSort", required = false) Integer coinSort,
            @RequestParam(value = "isSync", required = false) Integer isSync
    ) {
        CoinInfo item = coinInfoService.get(id);
        if (null == item) {
            return new ResponseEntity<>(ResultModel.error(), HttpStatus.OK);
        }
        if (coinId != null) {
            item.setCoinId(coinId);
        }
        if (coinEnglishName != null) {
            item.setCoinEnglishName(coinEnglishName);
        }
        if (coinSymbol != null) {
            item.setCoinSymbol(coinSymbol);
        }
        if (coinUrl != null) {
            item.setCoinUrl(coinUrl);
        }
        if (coinChineseName != null) {
            item.setCoinChineseName(coinChineseName);
        }
        if (coinContractAddress != null) {
            item.setCoinContractAddress(coinContractAddress);
        }
        if (coinDecimal != null) {
            item.setCoinDecimal(coinDecimal);
        }
        if (coinDecimalUsed != null) {
            item.setCoinDecimalUsed(coinDecimalUsed);
        }
        if (coinQuotesName != null) {
            item.setCoinQuotesName(coinQuotesName);
        }
        if (coinLocation != null) {
            item.setCoinLocation(coinLocation);
        }
        if (coinPriceRmb != null) {
            item.setCoinPriceRmb(coinPriceRmb);
        }
        if (coinPriceUsdt != null) {
            item.setCoinPriceUsdt(coinPriceUsdt);
        }
        if (coinFluctuation != null) {
            item.setCoinFluctuation(coinFluctuation);
        }
        if (coinPriceUpdatetime != null) {
            item.setCoinPriceUpdatetime(Tools.convertStringToDate(coinPriceUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinFluctuationUpdatetime != null) {
            item.setCoinFluctuationUpdatetime(Tools.convertStringToDate(coinFluctuationUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinPriceRequestpath != null) {
            item.setCoinPriceRequestpath(coinPriceRequestpath);
        }
        if (coinPriceJsonStructure != null) {
            item.setCoinPriceJsonStructure(coinPriceJsonStructure);
        }
        if (coinPriceRequestmethod != null) {
            item.setCoinPriceRequestmethod(coinPriceRequestmethod);
        }
        if (coinPriceRequestbody != null) {
            item.setCoinPriceRequestbody(coinPriceRequestbody);
        }
        if (coinFluctuationJsonStructure != null) {
            item.setCoinFluctuationJsonStructure(coinFluctuationJsonStructure);
        }
        if (coinFluctuationRequestpath != null) {
            item.setCoinFluctuationRequestpath(coinFluctuationRequestpath);
        }
        if (coinFluctuationRequestmethod != null) {
            item.setCoinFluctuationRequestmethod(coinFluctuationRequestmethod);
        }
        if (isdisplay != null) {
            item.setIsdisplay(isdisplay);
        }
        if (coinFluctuationRequestbody != null) {
            item.setCoinFluctuationRequestbody(coinFluctuationRequestbody);
        }
        if (coinSort != null) {
            item.setCoinSort(coinSort);
        }
        if (isSync != null) {
            item.setIsSync(isSync);
        }
        int update = coinInfoService.update(item);
        boolean result = update != 0;
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", result);
        return new ResponseEntity<>(ResultModel.ok(jsonObject), HttpStatus.OK);
    }

    @UserLoginToken
    @ApiOperation(value = "查询'币种信息'表中的某条记录")
    @RequestMapping(value = "/getCoinInfoById", method = {RequestMethod.GET}, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getCoinInfoById(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token") String token,
            @RequestParam(value = "id") Integer id
    ) {
        CoinInfo item = coinInfoService.get(id);
        if (null == item) {
            return new ResponseEntity<>(ResultModel.error(), HttpStatus.OK);
        }
        return new ResponseEntity<>(ResultModel.ok(item), HttpStatus.OK);
    }

    @UserLoginToken
    @ApiOperation(value = "查询'币种信息'表中的多条记录返回对象")
    @RequestMapping(value = "/coinInfoes", method = {RequestMethod.GET}, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getCoinInfoes(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token", required = false) String token,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sortItem", required = false, defaultValue = "id") String sortItem,
            @RequestParam(value = "sortOrder", required = false, defaultValue = "desc") String sortOrder,
            @RequestParam(value = "coinId", required = false) Integer coinId,
            @RequestParam(value = "coinEnglishName", required = false) String coinEnglishName,
            @RequestParam(value = "coinSymbol", required = false) String coinSymbol,
            @RequestParam(value = "coinUrl", required = false) String coinUrl,
            @RequestParam(value = "coinChineseName", required = false) String coinChineseName,
            @RequestParam(value = "coinContractAddress", required = false) String coinContractAddress,
            @RequestParam(value = "coinDecimal", required = false) Integer coinDecimal,
            @RequestParam(value = "coinDecimalUsed", required = false) Integer coinDecimalUsed,
            @RequestParam(value = "coinQuotesName", required = false) String coinQuotesName,
            @RequestParam(value = "coinLocation", required = false) String coinLocation,
            @RequestParam(value = "coinPriceRmb", required = false) Double coinPriceRmb,
            @RequestParam(value = "coinPriceUsdt", required = false) String coinPriceUsdt,
            @RequestParam(value = "coinFluctuation", required = false) String coinFluctuation,
            @RequestParam(value = "coinPriceUpdatetime", required = false) String coinPriceUpdatetime,
            @RequestParam(value = "coinFluctuationUpdatetime", required = false) String coinFluctuationUpdatetime,
            @RequestParam(value = "coinPriceRequestpath", required = false) String coinPriceRequestpath,
            @RequestParam(value = "coinPriceJsonStructure", required = false) String coinPriceJsonStructure,
            @RequestParam(value = "coinPriceRequestmethod", required = false) String coinPriceRequestmethod,
            @RequestParam(value = "coinPriceRequestbody", required = false) String coinPriceRequestbody,
            @RequestParam(value = "coinFluctuationJsonStructure", required = false) String coinFluctuationJsonStructure,
            @RequestParam(value = "coinFluctuationRequestpath", required = false) String coinFluctuationRequestpath,
            @RequestParam(value = "coinFluctuationRequestmethod", required = false) String coinFluctuationRequestmethod,
            @RequestParam(value = "isdisplay", required = false) Integer isdisplay,
            @RequestParam(value = "coinFluctuationRequestbody", required = false) String coinFluctuationRequestbody,
            @RequestParam(value = "coinSort", required = false) Integer coinSort,
            @RequestParam(value = "isSync", required = false) Integer isSync
    ) {
        CoinInfo item = new CoinInfo();
        if (coinId != null) {
            item.setCoinId(coinId);
        }
        if (coinEnglishName != null) {
            item.setCoinEnglishName(coinEnglishName);
        }
        if (coinSymbol != null) {
            item.setCoinSymbol(coinSymbol);
        }
        if (coinUrl != null) {
            item.setCoinUrl(coinUrl);
        }
        if (coinChineseName != null) {
            item.setCoinChineseName(coinChineseName);
        }
        if (coinContractAddress != null) {
            item.setCoinContractAddress(coinContractAddress);
        }
        if (coinDecimal != null) {
            item.setCoinDecimal(coinDecimal);
        }
        if (coinDecimalUsed != null) {
            item.setCoinDecimalUsed(coinDecimalUsed);
        }
        if (coinQuotesName != null) {
            item.setCoinQuotesName(coinQuotesName);
        }
        if (coinLocation != null) {
            item.setCoinLocation(coinLocation);
        }
        if (coinPriceRmb != null) {
            item.setCoinPriceRmb(coinPriceRmb);
        }
        if (coinPriceUsdt != null) {
            item.setCoinPriceUsdt(coinPriceUsdt);
        }
        if (coinFluctuation != null) {
            item.setCoinFluctuation(coinFluctuation);
        }
        if (coinPriceUpdatetime != null) {
            item.setCoinPriceUpdatetime(Tools.convertStringToDate(coinPriceUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinFluctuationUpdatetime != null) {
            item.setCoinFluctuationUpdatetime(Tools.convertStringToDate(coinFluctuationUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinPriceRequestpath != null) {
            item.setCoinPriceRequestpath(coinPriceRequestpath);
        }
        if (coinPriceJsonStructure != null) {
            item.setCoinPriceJsonStructure(coinPriceJsonStructure);
        }
        if (coinPriceRequestmethod != null) {
            item.setCoinPriceRequestmethod(coinPriceRequestmethod);
        }
        if (coinPriceRequestbody != null) {
            item.setCoinPriceRequestbody(coinPriceRequestbody);
        }
        if (coinFluctuationJsonStructure != null) {
            item.setCoinFluctuationJsonStructure(coinFluctuationJsonStructure);
        }
        if (coinFluctuationRequestpath != null) {
            item.setCoinFluctuationRequestpath(coinFluctuationRequestpath);
        }
        if (coinFluctuationRequestmethod != null) {
            item.setCoinFluctuationRequestmethod(coinFluctuationRequestmethod);
        }
        if (isdisplay != null) {
            item.setIsdisplay(isdisplay);
        }
        if (coinFluctuationRequestbody != null) {
            item.setCoinFluctuationRequestbody(coinFluctuationRequestbody);
        }
        if (coinSort != null) {
            item.setCoinSort(coinSort);
        }
        if (isSync != null) {
            item.setIsSync(isSync);
        }
        PageInfo<CoinInfo> list = coinInfoService.getListWithPaging(pageNum, pageSize, sortItem, sortOrder, item);
        return new ResponseEntity<>(ResultModel.ok(list), HttpStatus.OK);
    }

    @UserLoginToken
    @ApiOperation(value = "查询'币种信息'表中的多条记录返回自定义JSONObject")
    @RequestMapping(value = "/coinInfoesObject", method = {RequestMethod.GET}, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getCoinInfoesObject(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token", required = false) String token,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sortItem", required = false, defaultValue = "id") String sortItem,
            @RequestParam(value = "sortOrder", required = false, defaultValue = "desc") String sortOrder,
            @RequestParam(value = "coinId", required = false) Integer coinId,
            @RequestParam(value = "coinEnglishName", required = false) String coinEnglishName,
            @RequestParam(value = "coinSymbol", required = false) String coinSymbol,
            @RequestParam(value = "coinUrl", required = false) String coinUrl,
            @RequestParam(value = "coinChineseName", required = false) String coinChineseName,
            @RequestParam(value = "coinContractAddress", required = false) String coinContractAddress,
            @RequestParam(value = "coinDecimal", required = false) Integer coinDecimal,
            @RequestParam(value = "coinDecimalUsed", required = false) Integer coinDecimalUsed,
            @RequestParam(value = "coinQuotesName", required = false) String coinQuotesName,
            @RequestParam(value = "coinLocation", required = false) String coinLocation,
            @RequestParam(value = "coinPriceRmb", required = false) Double coinPriceRmb,
            @RequestParam(value = "coinPriceUsdt", required = false) String coinPriceUsdt,
            @RequestParam(value = "coinFluctuation", required = false) String coinFluctuation,
            @RequestParam(value = "coinPriceUpdatetime", required = false) String coinPriceUpdatetime,
            @RequestParam(value = "coinFluctuationUpdatetime", required = false) String coinFluctuationUpdatetime,
            @RequestParam(value = "coinPriceRequestpath", required = false) String coinPriceRequestpath,
            @RequestParam(value = "coinPriceJsonStructure", required = false) String coinPriceJsonStructure,
            @RequestParam(value = "coinPriceRequestmethod", required = false) String coinPriceRequestmethod,
            @RequestParam(value = "coinPriceRequestbody", required = false) String coinPriceRequestbody,
            @RequestParam(value = "coinFluctuationJsonStructure", required = false) String coinFluctuationJsonStructure,
            @RequestParam(value = "coinFluctuationRequestpath", required = false) String coinFluctuationRequestpath,
            @RequestParam(value = "coinFluctuationRequestmethod", required = false) String coinFluctuationRequestmethod,
            @RequestParam(value = "isdisplay", required = false) Integer isdisplay,
            @RequestParam(value = "coinFluctuationRequestbody", required = false) String coinFluctuationRequestbody,
            @RequestParam(value = "coinSort", required = false) Integer coinSort,
            @RequestParam(value = "isSync", required = false) Integer isSync
    ) {
        CoinInfo item = new CoinInfo();
        if (coinId != null) {
            item.setCoinId(coinId);
        }
        if (coinEnglishName != null) {
            item.setCoinEnglishName(coinEnglishName);
        }
        if (coinSymbol != null) {
            item.setCoinSymbol(coinSymbol);
        }
        if (coinUrl != null) {
            item.setCoinUrl(coinUrl);
        }
        if (coinChineseName != null) {
            item.setCoinChineseName(coinChineseName);
        }
        if (coinContractAddress != null) {
            item.setCoinContractAddress(coinContractAddress);
        }
        if (coinDecimal != null) {
            item.setCoinDecimal(coinDecimal);
        }
        if (coinDecimalUsed != null) {
            item.setCoinDecimalUsed(coinDecimalUsed);
        }
        if (coinQuotesName != null) {
            item.setCoinQuotesName(coinQuotesName);
        }
        if (coinLocation != null) {
            item.setCoinLocation(coinLocation);
        }
        if (coinPriceRmb != null) {
            item.setCoinPriceRmb(coinPriceRmb);
        }
        if (coinPriceUsdt != null) {
            item.setCoinPriceUsdt(coinPriceUsdt);
        }
        if (coinFluctuation != null) {
            item.setCoinFluctuation(coinFluctuation);
        }
        if (coinPriceUpdatetime != null) {
            item.setCoinPriceUpdatetime(Tools.convertStringToDate(coinPriceUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinFluctuationUpdatetime != null) {
            item.setCoinFluctuationUpdatetime(Tools.convertStringToDate(coinFluctuationUpdatetime, "yyyy-MM-dd HH:mm:ss"));
        }
        if (coinPriceRequestpath != null) {
            item.setCoinPriceRequestpath(coinPriceRequestpath);
        }
        if (coinPriceJsonStructure != null) {
            item.setCoinPriceJsonStructure(coinPriceJsonStructure);
        }
        if (coinPriceRequestmethod != null) {
            item.setCoinPriceRequestmethod(coinPriceRequestmethod);
        }
        if (coinPriceRequestbody != null) {
            item.setCoinPriceRequestbody(coinPriceRequestbody);
        }
        if (coinFluctuationJsonStructure != null) {
            item.setCoinFluctuationJsonStructure(coinFluctuationJsonStructure);
        }
        if (coinFluctuationRequestpath != null) {
            item.setCoinFluctuationRequestpath(coinFluctuationRequestpath);
        }
        if (coinFluctuationRequestmethod != null) {
            item.setCoinFluctuationRequestmethod(coinFluctuationRequestmethod);
        }
        if (isdisplay != null) {
            item.setIsdisplay(isdisplay);
        }
        if (coinFluctuationRequestbody != null) {
            item.setCoinFluctuationRequestbody(coinFluctuationRequestbody);
        }
        if (coinSort != null) {
            item.setCoinSort(coinSort);
        }
        if (isSync != null) {
            item.setIsSync(isSync);
        }
        PageInfo<JSONObject> list = coinInfoService.getListWithObject(pageNum, pageSize, sortItem, sortOrder, item);
        List<JSONObject> list1 = list.getList();
        List<JSONObject> collect = list1.stream().map(ls -> {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("coinId", ls.getInteger("coinId"));
            jsonObject.put("coinEnglishName", ls.getString("coinEnglishName"));
            jsonObject.put("coinSymbol", ls.getString("coinSymbol"));
            jsonObject.put("coinUrl", ls.getString("coinUrl"));
            jsonObject.put("coinChineseName", ls.getString("coinChineseName"));
            jsonObject.put("coinContractAddress", ls.getString("coinContractAddress"));
            jsonObject.put("coinDecimal", ls.getInteger("coinDecimal"));
            jsonObject.put("coinDecimalUsed", ls.getInteger("coinDecimalUsed"));
            jsonObject.put("coinQuotesName", ls.getString("coinQuotesName"));
            jsonObject.put("coinLocation", ls.getString("coinLocation"));
            jsonObject.put("coinPriceRmb", ls.getDouble("coinPriceRmb"));
            jsonObject.put("coinPriceUsdt", ls.getString("coinPriceUsdt"));
            jsonObject.put("coinFluctuation", ls.getString("coinFluctuation"));
            jsonObject.put("coinPriceUpdatetime", ls.getDate("coinPriceUpdatetime"));
            jsonObject.put("coinFluctuationUpdatetime", ls.getDate("coinFluctuationUpdatetime"));
            jsonObject.put("coinPriceRequestpath", ls.getString("coinPriceRequestpath"));
            jsonObject.put("coinPriceJsonStructure", ls.getString("coinPriceJsonStructure"));
            jsonObject.put("coinPriceRequestmethod", ls.getString("coinPriceRequestmethod"));
            jsonObject.put("coinPriceRequestbody", ls.getString("coinPriceRequestbody"));
            jsonObject.put("coinFluctuationJsonStructure", ls.getString("coinFluctuationJsonStructure"));
            jsonObject.put("coinFluctuationRequestpath", ls.getString("coinFluctuationRequestpath"));
            jsonObject.put("coinFluctuationRequestmethod", ls.getString("coinFluctuationRequestmethod"));
            jsonObject.put("isdisplay", ls.getInteger("isdisplay"));
            jsonObject.put("coinFluctuationRequestbody", ls.getString("coinFluctuationRequestbody"));
            jsonObject.put("coinSort", ls.getInteger("coinSort"));
            jsonObject.put("isSync", ls.getInteger("isSync"));
            return jsonObject;
        }).collect(Collectors.toList());
        list.setList(collect);
        return new ResponseEntity<>(ResultModel.ok(list), HttpStatus.OK);
    }

    @UserLoginToken
    @ApiOperation(value = "获取币种列表")
    @RequestMapping(value = "/coinInfo", method = {RequestMethod.GET}, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object coinInfo(
            HttpServletRequest request,
            @RequestHeader(value = "X-Auth-Token", required = false) String token,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sortItem", required = false, defaultValue = "id") String sortItem,
            @RequestParam(value = "sortOrder", required = false, defaultValue = "desc") String sortOrder
    ) {
        CoinInfo item = new CoinInfo();
        PageInfo<JSONObject> list = coinInfoService.getListWithObject(1, pageSize, sortItem, sortOrder, item);
        List<JSONObject> list1 = list.getList();
        List<JSONObject> collect = list1.stream().map(ls -> {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("coinId", ls.getInteger("coinId"));
            jsonObject.put("coinSymbol", ls.getString("coinSymbol"));
            return jsonObject;
        }).collect(Collectors.toList());
        list.setList(collect);
        return new ResponseEntity<>(ResultModel.ok(list), HttpStatus.OK);
    }
}
